package com.we.risk.smsInfo;

import com.we.risk.smsInfo.utils.smsInfoTools;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

import static com.we.risk.smsInfo.SmsType.*;

public class SmsCategory {

    public HashMap<String, Object> resMap;
    public HashSet<String> daySet;
    public HashSet<String> wkdyDaySet;
    public HashSet<String> wkedDaySet;
    public HashSet<String> wkedDaySet2; //
    public HashSet<String> dayTimeDaySet;
    public HashSet<String> nightDaySet;
    public HashSet<String> numSet;
    public HashSet<String> orgSet;
    public HashSet<String> wkedOrgSet;
    public HashSet<String> wkdyOrgSet;
    public HashSet<String> dayTimeOrgSet;
    public HashSet<String> nightOrgSet;
    public HashMap<String, Integer> dateSmsNum;
    /** bank */
    public HashSet<String> coDaySet;

    public HashSet<String> ciDaySet;
    public HashSet<String> repayDaySet;
    public HashSet<String> coOrgSet;
    public HashSet<String> ciOrgSet;
    public HashSet<String> repayOrgSet;
    public HashSet<String> weekdayCoDaySet;
    public HashSet<String> weekdayCiDaySet;
    public HashSet<String> weekdayRepayDaySet;
    public HashSet<String> weekdayCoOrgSet;
    public HashSet<String> weekdayCiOrgSet;
    public HashSet<String> weekdayRepayOrgSet;
    public HashSet<String> weekendCoDaySet;
    public HashSet<String> weekendCiDaySet;
    public HashSet<String> weekendRepayDaySet;
    public HashSet<String> weekendCoOrgSet;
    public HashSet<String> weekendCiOrgSet;
    public HashSet<String> weekendRepayOrgSet;

    public ArrayList<BigDecimal> remainAmtList;
    public ArrayList<BigDecimal> outAmtList;
    public ArrayList<BigDecimal> inAmtList;
    public ArrayList<BigDecimal> weekDayRemainAmtList;
    public ArrayList<BigDecimal> weekDayRemainAmtList2; //
    public ArrayList<BigDecimal> weekDayOutAmtList;
    public ArrayList<BigDecimal> weekDayInAmtList;
    public ArrayList<BigDecimal> weekDayInAmtList2; //
    public ArrayList<BigDecimal> weekendRemainAmtList;
    public ArrayList<BigDecimal> weekendRemainAmtList2; //
    public ArrayList<BigDecimal> weekendOutAmtList;
    public ArrayList<BigDecimal> weekendInAmtList;

    /** crdt */
    public ArrayList<BigDecimal> crdtAmtList;

    public ArrayList<BigDecimal> crdtcosuAmtList;
    public ArrayList<BigDecimal> weekDaycrdtAmtList;
    public ArrayList<BigDecimal> weekDaycrdtAmtList2; //
    public ArrayList<BigDecimal> weekDaycrdtcosuAmtList;
    public ArrayList<BigDecimal> weekendcrdtAmtList;
    public ArrayList<BigDecimal> weekendcrdtcosuAmtList;

    /** itnt */
    public HashSet<String> applySuccDaySet;

    public HashSet<String> applySuccOrgSet;
    public HashSet<String> wkdyApplySuccDaySet;
    public HashSet<String> wkedApplySuccDaySet;
    public HashSet<String> wkdyApplySuccOrgSet;
    public HashSet<String> wkedApplySuccOrgSet;
    public HashSet<String> repayRemindDaySet;
    public HashSet<String> repayRemindOrgSet;
    public HashSet<String> wkdyRepayRemindDaySet;
    public HashSet<String> wkedRepayRemindDaySet;
    public HashSet<String> wkdyRepayRemindOrgSet;
    public HashSet<String> wkedRepayRemindOrgSet;
    public HashSet<String> repaySuccDaySet;
    public HashSet<String> repaySuccOrgSet;
    public HashSet<String> wkdyRepaySuccDaySet;
    public HashSet<String> wkedRepaySuccDaySet;
    public HashSet<String> wkdyRepaySuccOrgSet;
    public HashSet<String> wkedRepaySuccOrgSet;
    public HashSet<String> repayFailDaySet;
    public HashSet<String> repayFailOrgSet;
    public HashSet<String> wkdyRepayFailDaySet;
    public HashSet<String> wkedRepayFailDaySet;
    public HashSet<String> wkdyRepayFailOrgSet;
    public HashSet<String> wkedRepayFailOrgSet;

    /** ITNT */
    public ArrayList<BigDecimal> loanLineAmtList;

    public ArrayList<BigDecimal> loanRepayAmtList;
    public ArrayList<BigDecimal> weekDayLoanLineAmtList;
    public ArrayList<BigDecimal> weekDayLoanRepayAmtList;
    public ArrayList<BigDecimal> weekDayLoanRepayAmtList2; //
    public ArrayList<BigDecimal> weekendLoanLineAmtList;
    public ArrayList<BigDecimal> weekendLoanRepayAmtList;

    /** loan od */
    public HashSet<String> loanOdDaySet;

    public HashSet<String> loanOdOrgSet;

    public String cate;
    public int cnt; // 短信条数
    public int wked_cnt;
    public int wked_cnt2; //
    public int wkdy_cnt;
    public int night_cnt;
    public int daytime_cnt;
    public int recv_cnt;
    public int recv_wked_cnt;
    public int recv_wkdy_cnt;
    public int recv_night_cnt;
    public int recv_daytime_cnt;
    public int recv_read_cnt;
    public int recv_unread_cnt;
    public int sent_cnt;
    public int sent_night_cnt;
    public int sent_daytime_cnt;
    public int sent_wked_cnt;
    public int sent_wkdy_cnt;
    public int sent_wkdy_cnt2; //
    public int earliest_gap_days = Integer.MIN_VALUE;
    public int recent_gap_days = Integer.MAX_VALUE;

    // bank
    public int co_cnt;
    public int ci_cnt;
    public int repay_cnt;
    public int weekday_co_cnt;
    public int weekday_co_cnt_2;
    public int weekday_ci_cnt;
    public int weekday_repay_cnt;
    public int weekend_co_cnt;
    public int weekend_ci_cnt;
    public int weekend_repay_cnt;

    // itnt
    public int apply_success_cnt;
    public int weekday_apply_success_cnt;
    public int weekend_apply_success_cnt;
    public int repay_remind_cnt;
    public int weekday_repay_remind_cnt;
    public int weekend_repay_remind_cnt;
    public int repay_succ_cnt;
    public int weekday_repay_succ_cnt;
    public int weekend_repay_succ_cnt;
    public int repay_fail_cnt;
    public int weekday_repay_fail_cnt;
    public int weekday_repay_fail_cnt2; //
    public int weekend_repay_fail_cnt;

    // loan od
    public int loan_od_cnt;

    public SmsCategory(String category) {
        cate = category;
        resMap = new HashMap<>();
        daySet = new HashSet<>();
        wkdyDaySet = new HashSet<>();
        wkedDaySet = new HashSet<>();

        if (cate.equals(BANK)) {
            coDaySet = new HashSet<>();
            ciDaySet = new HashSet<>();
            repayDaySet = new HashSet<>();
            coOrgSet = new HashSet<>();
            ciOrgSet = new HashSet<>();
            repayOrgSet = new HashSet<>();
            weekdayCoDaySet = new HashSet<>();
            weekdayCiDaySet = new HashSet<>();
            weekdayRepayDaySet = new HashSet<>();
            weekdayCoOrgSet = new HashSet<>();
            weekdayCiOrgSet = new HashSet<>();
            weekdayRepayOrgSet = new HashSet<>();
            weekendCoDaySet = new HashSet<>();
            weekendCiDaySet = new HashSet<>();
            weekendRepayDaySet = new HashSet<>();
            weekendCoOrgSet = new HashSet<>();
            weekendCiOrgSet = new HashSet<>();
            weekendRepayOrgSet = new HashSet<>();

            remainAmtList = new ArrayList<>();
            outAmtList = new ArrayList<>();
            inAmtList = new ArrayList<>();
            weekDayRemainAmtList = new ArrayList<>();
            weekDayRemainAmtList2 = new ArrayList<>();
            weekDayOutAmtList = new ArrayList<>();
            weekDayInAmtList = new ArrayList<>();
            weekDayInAmtList2 = new ArrayList<>();
            weekendRemainAmtList = new ArrayList<>();
            weekendRemainAmtList2 = new ArrayList<>();
            weekendOutAmtList = new ArrayList<>();
            weekendInAmtList = new ArrayList<>();
        }

        if (cate.equals(CRDT)) {
            crdtAmtList = new ArrayList<>();
            crdtcosuAmtList = new ArrayList<>();
            weekDaycrdtAmtList = new ArrayList<>();
            weekDaycrdtAmtList2 = new ArrayList<>();
            weekDaycrdtcosuAmtList = new ArrayList<>();
            weekendcrdtAmtList = new ArrayList<>();
            weekendcrdtcosuAmtList = new ArrayList<>();
        }

        if (cate.equals(LOAN)) {
            applySuccDaySet = new HashSet<>();
            applySuccOrgSet = new HashSet<>();
            wkdyApplySuccDaySet = new HashSet<>();
            wkedApplySuccDaySet = new HashSet<>();
            wkdyApplySuccOrgSet = new HashSet<>();
            wkedApplySuccOrgSet = new HashSet<>();
            repayRemindDaySet = new HashSet<>();
            repayRemindOrgSet = new HashSet<>();
            wkdyRepayRemindDaySet = new HashSet<>();
            wkedRepayRemindDaySet = new HashSet<>();
            wkdyRepayRemindOrgSet = new HashSet<>();
            wkedRepayRemindOrgSet = new HashSet<>();
            repaySuccDaySet = new HashSet<>();
            repaySuccOrgSet = new HashSet<>();
            wkdyRepaySuccDaySet = new HashSet<>();
            wkedRepaySuccDaySet = new HashSet<>();
            wkdyRepaySuccOrgSet = new HashSet<>();
            wkedRepaySuccOrgSet = new HashSet<>();
            repayFailDaySet = new HashSet<>();
            repayFailOrgSet = new HashSet<>();
            wkdyRepayFailDaySet = new HashSet<>();
            wkedRepayFailDaySet = new HashSet<>();
            wkdyRepayFailOrgSet = new HashSet<>();
            wkedRepayFailOrgSet = new HashSet<>();

            loanLineAmtList = new ArrayList<>();
            loanRepayAmtList = new ArrayList<>();
            weekDayLoanLineAmtList = new ArrayList<>();
            weekDayLoanRepayAmtList = new ArrayList<>();
            weekDayLoanRepayAmtList2 = new ArrayList<>();
            weekendLoanLineAmtList = new ArrayList<>();
            weekendLoanRepayAmtList = new ArrayList<>();
        }

        if (cate.equals(OD)) {
            loanOdDaySet = new HashSet<>();
            loanOdOrgSet = new HashSet<>();
        }

        dayTimeDaySet = new HashSet<>();
        nightDaySet = new HashSet<>();
        numSet = new HashSet<>();
        orgSet = new HashSet<>();
        wkedOrgSet = new HashSet<>();
        wkdyOrgSet = new HashSet<>();
        dayTimeOrgSet = new HashSet<>();
        nightOrgSet = new HashSet<>();
        dateSmsNum = new HashMap<>();
    }

    public void smsBaseProcess(SmsInfoBasic basicInfo, SimpleDateFormat sdf, Integer diffDays) {
        cnt += 1;
        int isWeekend = basicInfo.getIsWeekend();
        int isWeekend2 = basicInfo.getIsWeekend2();
        int isDaytime = basicInfo.getIsDaytime();
        int isRead = basicInfo.getIsRead();
        int isRecv = basicInfo.getIsRecv();
        String phoneNum = basicInfo.getPhoneNum();
        String body_name = basicInfo.getBody_name();
        long recvTime = basicInfo.getRecvTime();
        String date = sdf.format(new Date(recvTime));
        earliest_gap_days = (earliest_gap_days > diffDays ? earliest_gap_days : diffDays);
        recent_gap_days = (recent_gap_days < diffDays ? recent_gap_days : diffDays);

        if (phoneNum != null) {
            numSet.add(phoneNum);
        }
        daySet.add(date);
        if (body_name != null) {
            orgSet.add(body_name);
        }

        if (isWeekend == 1) {
            wked_cnt += 1;
        } else {
            wkdy_cnt += 1;
        }

        if (isWeekend2 == 1) {
            wked_cnt2 += 1;
        }

        if (isDaytime == 1) {
            daytime_cnt += 1;
        } else {
            night_cnt += 1;
        }

        if (isRecv != 1) {
            sent_cnt += 1;
            if (isWeekend == 1) {
                sent_wked_cnt += 1;
            } else {
                sent_wkdy_cnt += 1;
            }

            if (isWeekend2 != 1) {
                sent_wkdy_cnt2 += 1;
            }

            if (isDaytime == 1) {
                sent_daytime_cnt += 1;
            } else {
                sent_night_cnt += 1;
            }
        } else {
            recv_cnt += 1;
            if (isWeekend == 1) {
                recv_wked_cnt += 1;
            } else {
                recv_wkdy_cnt += 1;
            }
            if (isDaytime == 1) {
                recv_daytime_cnt += 1;
            } else {
                recv_night_cnt += 1;
            }
            if (isRead == 1) {
                recv_read_cnt += 1;
            } else if(isRead == 0){
                recv_unread_cnt += 1;
            }
        }
    }

    private void smsBaseCalcLabel(String diffDays) {
        resMap.put("sms_base_total_" + diffDays + "_cnt", cnt);
        resMap.put("sms_base_total_wked_" + diffDays + "_cnt", wked_cnt);
        if (diffDays.equals("d30") || diffDays.equals("d180")) {
            resMap.put("sms_base_total_wked_" + diffDays + "_cnt_2", wked_cnt2);
        }
        resMap.put("sms_base_total_wkdy_" + diffDays + "_cnt", wkdy_cnt);
        resMap.put("sms_base_total_daytime_" + diffDays + "_cnt", daytime_cnt);
        resMap.put("sms_base_total_night_" + diffDays + "_cnt", night_cnt);

        resMap.put("sms_base_total_opposites_" + diffDays + "_cnt", numSet.size());
        resMap.put("sms_base_total_" + diffDays + "_days", daySet.size());

        resMap.put("sms_base_receive_" + diffDays + "_cnt", recv_cnt);
        resMap.put("sms_base_receive_wked_" + diffDays + "_cnt", recv_wked_cnt);
        resMap.put("sms_base_receive_wkdy_" + diffDays + "_cnt", recv_wkdy_cnt);
        resMap.put("sms_base_receive_daytime_" + diffDays + "_cnt", recv_daytime_cnt);
        resMap.put("sms_base_receive_night_" + diffDays + "_cnt", recv_night_cnt);
        resMap.put("sms_base_receive_read_" + diffDays + "_cnt", recv_read_cnt);
        resMap.put("sms_base_receive_unread_" + diffDays + "_cnt", recv_unread_cnt);
        resMap.put("sms_base_sent_" + diffDays + "_cnt", sent_cnt);
        resMap.put("sms_base_sent_wked_" + diffDays + "_cnt", sent_wked_cnt);
        resMap.put("sms_base_sent_wkdy_" + diffDays + "_cnt", sent_wkdy_cnt);
        if (diffDays.equals("d30")) {
            resMap.put("sms_base_sent_" + diffDays + "_wkdy_cnt_2", sent_wkdy_cnt2);
            resMap.put("sms_base_sent_" + diffDays + "_wkdy_cnt", sent_wkdy_cnt);
        }
        resMap.put("sms_base_sent_daytime_" + diffDays + "_cnt", sent_daytime_cnt);
        resMap.put("sms_base_sent_night_" + diffDays + "_cnt", sent_night_cnt);

        if (diffDays.equals("d365")) {
            resMap.put("sms_earlist_gap_days", earliest_gap_days);
            resMap.put("sms_recent_gap_days", recent_gap_days);
        }
    }

    public void smsCateProcess(SmsInfoBasic basicInfo, SimpleDateFormat sdf) {
        cnt += 1;
        long recvTime = basicInfo.getRecvTime();
        String date = sdf.format(new Date(recvTime));
        daySet.add(date);

        String body_name = basicInfo.getBody_name();
        if (body_name != null) {
            orgSet.add(body_name);
        }

        /** 单日短信最大值 */
        Integer smsNum = dateSmsNum.get(date);
        if (smsNum == null) {
            dateSmsNum.put(date, 1);
        } else {
            dateSmsNum.put(date, smsNum + 1);
        }

        if (cate.equals(SmsType.SERV)) {
            int isDaytime = basicInfo.getIsDaytime();

            if (isDaytime == 1) {
                daytime_cnt += 1;
                dayTimeDaySet.add(date);
                if (body_name != null) {
                    dayTimeOrgSet.add(body_name);
                }
            } else {
                night_cnt += 1;
                nightDaySet.add(date);
                if (body_name != null) {
                    nightOrgSet.add(body_name);
                }
            }
        }
    }

    private void smsCateCalcLabel(String diffDays) {
        resMap.put(cate + "_" + diffDays + "_cnt", cnt);
        resMap.put(cate + "_" + diffDays + "_org_cnt", orgSet.size());
        resMap.put(cate + "_" + diffDays + "_days", daySet.size());
        if (cate.equals(SERV)) {
            resMap.put(cate + "_daytime_" + diffDays + "_cnt", daytime_cnt);
            resMap.put(cate + "_daytime_" + diffDays + "_org_cnt", dayTimeOrgSet.size());
            resMap.put(cate + "_daytime_" + diffDays + "_days", dayTimeDaySet.size());
            resMap.put(cate + "_night_" + diffDays + "_cnt", night_cnt);
            resMap.put(cate + "_night_" + diffDays + "_org_cnt", nightOrgSet.size());
            resMap.put(cate + "_night_" + diffDays + "_days", nightDaySet.size());
        }
        if (!dateSmsNum.isEmpty()) {
            int tmpMax = Integer.MIN_VALUE;
            Collection<Integer> values = dateSmsNum.values();
            Iterator<Integer> iterator = values.iterator();
            while (iterator.hasNext()) {
                Integer next = iterator.next();
                tmpMax = (tmpMax > next ? tmpMax : next);
            }
            resMap.put(cate + "_" + diffDays + "_daycnt_max", tmpMax);
        }
    }

    public void smsBankProcess(SmsInfoBasic basicInfo, SimpleDateFormat sdf) {
        cnt += 1; // 银行类总条数
        int isCashIn = basicInfo.getIsCashIn();
        int isCashOut = basicInfo.getIsCashOut();
        int isLoanRepay = basicInfo.getIsLoanRepay();
        String body_name = basicInfo.getBody_name();
        long recvTime = basicInfo.getRecvTime();
        String date = sdf.format(new Date(recvTime));

        daySet.add(date);
        if (body_name != null) {
            orgSet.add(body_name);
        }

        int isWeekend = basicInfo.getIsWeekend();
        int isWeekend2 = basicInfo.getIsWeekend2();
        if (isWeekend == 1) {
            wked_cnt += 1;
            wkedDaySet.add(date);
            if (body_name != null) {
                wkedOrgSet.add(body_name);
            }
        } else {
            wkdy_cnt += 1;
            wkdyDaySet.add(date);
            if (body_name != null) {
                wkdyOrgSet.add(body_name);
            }
        }

        if (isWeekend2 == 1) {
            wked_cnt2 += 1;
        }

        /** amt may be null */
        BigDecimal cashOutAmt = basicInfo.getCashOutAmt();
        BigDecimal cashInAmt = basicInfo.getCashInAmt();
        BigDecimal bankRemainAmt = basicInfo.getBankRemainAmt();
        /** need to calc min max avg std */
        if (cashInAmt != null) {
            inAmtList.add(cashInAmt);
            if (isWeekend == 1) {
                weekendInAmtList.add(cashInAmt);
            } else {
                weekDayInAmtList.add(cashInAmt);
            }
            if (isWeekend2 != 1) {
                weekDayInAmtList2.add(cashInAmt);
            }
        }
        if (cashOutAmt != null) {
            outAmtList.add(cashOutAmt);
            if (isWeekend == 1) {
                weekendOutAmtList.add(cashOutAmt);
            } else {
                weekDayOutAmtList.add(cashOutAmt);
            }
        }

        if (bankRemainAmt != null) {
            remainAmtList.add(bankRemainAmt);
            if (isWeekend == 1) {
                weekendRemainAmtList.add(bankRemainAmt);
            } else {
                weekDayRemainAmtList.add(bankRemainAmt);
            }
            if (isWeekend2 == 1) {
                weekendRemainAmtList2.add(bankRemainAmt);
            } else {
                weekDayRemainAmtList2.add(bankRemainAmt);
            }
        }

        if (isCashIn == 1) {
            ci_cnt += 1;
            if (body_name != null) {
                ciOrgSet.add(body_name);
            }
            ciDaySet.add(date);

            if (isWeekend == 1) {
                weekend_ci_cnt += 1;
                if (body_name != null) {
                    weekendCiOrgSet.add(body_name);
                }
                weekendCiDaySet.add(date);
            } else {
                weekday_ci_cnt += 1;
                if (body_name != null) {
                    weekdayCiOrgSet.add(body_name);
                }
                weekdayCiDaySet.add(date);
            }
        }

        if (isCashOut == 1) {
            co_cnt += 1;
            if (body_name != null) {
                coOrgSet.add(body_name);
            }
            coDaySet.add(date);

            if (isWeekend == 1) {
                weekend_co_cnt += 1;
                if (body_name != null) {
                    weekendCoOrgSet.add(body_name);
                }
                weekendCoDaySet.add(date);
            } else {
                weekday_co_cnt += 1;
                if (body_name != null) {
                    weekdayCoOrgSet.add(body_name);
                }
                weekdayCoDaySet.add(date);
            }

            if (isWeekend2 != 1) {
                weekday_co_cnt_2 += 1;
            }
        }

        if (isLoanRepay == 1) {
            repay_cnt += 1;
            if (body_name != null) {
                repayOrgSet.add(body_name);
            }
            repayDaySet.add(date);

            if (isWeekend == 1) {
                weekend_repay_cnt += 1;
                if (body_name != null) {
                    weekendRepayOrgSet.add(body_name);
                }
                weekendRepayDaySet.add(date);
            } else {
                weekday_repay_cnt += 1;
                if (body_name != null) {
                    weekdayRepayOrgSet.add(body_name);
                }
                weekdayRepayDaySet.add(date);
            }
        }
    }

    private void smsBankCalcLabel(String diffDays) {
        resMap.put(cate + "_" + diffDays + "_cnt", cnt);
        resMap.put(cate + "_co_" + diffDays + "_cnt", co_cnt);
        resMap.put(cate + "_ci_" + diffDays + "_cnt", ci_cnt);
        resMap.put(cate + "_repay_" + diffDays + "_cnt", repay_cnt);

        resMap.put(cate + "_" + diffDays + "_weekday_cnt", wkdy_cnt);
        resMap.put(cate + "_co_" + diffDays + "_weekday_cnt", weekday_co_cnt);
        if (diffDays.equals("d30")) {
            resMap.put(cate + "_co_" + diffDays + "_weekday_cnt_2", weekday_co_cnt_2);
        }
        resMap.put(cate + "_ci_" + diffDays + "_weekday_cnt", weekday_ci_cnt);
        resMap.put(cate + "_repay_" + diffDays + "_weekday_cnt", weekday_repay_cnt);

        resMap.put(cate + "_" + diffDays + "_weekend_cnt", wked_cnt);
        if (diffDays.equals("d90")) {
            resMap.put(cate + "_" + diffDays + "_weekend_cnt_2", wked_cnt2);
        }
        resMap.put(cate + "_co_" + diffDays + "_weekend_cnt", weekend_co_cnt);
        resMap.put(cate + "_ci_" + diffDays + "_weekend_cnt", weekend_ci_cnt);
        resMap.put(cate + "_repay_" + diffDays + "_weekend_cnt", weekend_repay_cnt);

        resMap.put(cate + "_" + diffDays + "_org_cnt", orgSet.size());
        resMap.put(cate + "_co_" + diffDays + "_org_cnt", coOrgSet.size());
        resMap.put(cate + "_ci_" + diffDays + "_org_cnt", ciOrgSet.size());
        resMap.put(cate + "_repay_" + diffDays + "_org_cnt", repayOrgSet.size());

        resMap.put(cate + "_" + diffDays + "_weekday_org_cnt", wkdyOrgSet.size());
        resMap.put(cate + "_co_" + diffDays + "_weekday_org_cnt", weekdayCoOrgSet.size());
        resMap.put(cate + "_ci_" + diffDays + "_weekday_org_cnt", weekdayCiOrgSet.size());
        resMap.put(cate + "_repay_" + diffDays + "_weekday_org_cnt", weekdayRepayOrgSet.size());

        resMap.put(cate + "_" + diffDays + "_weekend_org_cnt", wkedOrgSet.size());
        resMap.put(cate + "_co_" + diffDays + "_weekend_org_cnt", weekendCoOrgSet.size());
        resMap.put(cate + "_ci_" + diffDays + "_weekend_org_cnt", weekendCiOrgSet.size());
        resMap.put(cate + "_repay_" + diffDays + "_weekend_org_cnt", weekendRepayOrgSet.size());

        resMap.put(cate + "_" + diffDays + "_days", daySet.size());
        resMap.put(cate + "_co_" + diffDays + "_days", coDaySet.size());
        resMap.put(cate + "_ci_" + diffDays + "_days", ciDaySet.size());
        resMap.put(cate + "_repay_" + diffDays + "_days", repayDaySet.size());

        resMap.put(cate + "_" + diffDays + "_weekday_days", wkdyDaySet.size());
        resMap.put(cate + "_co_" + diffDays + "_weekday_days", weekdayCoDaySet.size());
        resMap.put(cate + "_ci_" + diffDays + "_weekday_days", weekdayCiDaySet.size());
        resMap.put(cate + "_repay_" + diffDays + "_weekday_days", weekdayRepayDaySet.size());

        resMap.put(cate + "_" + diffDays + "_weekend_days", wkedDaySet.size());
        resMap.put(cate + "_co_" + diffDays + "_weekend_days", weekendCoDaySet.size());
        resMap.put(cate + "_ci_" + diffDays + "_weekend_days", weekendCiDaySet.size());
        resMap.put(cate + "_repay_" + diffDays + "_weekend_days", weekendRepayDaySet.size());

        Object[] remainAmts = smsInfoTools.calcMinMaxAvgStd(remainAmtList);
        if (remainAmts != null) {
            resMap.put(cate + "_" + diffDays + "_remain_amt_min", remainAmts[0]);
            resMap.put(cate + "_" + diffDays + "_remain_amt_max", remainAmts[1]);
            resMap.put(cate + "_" + diffDays + "_remain_amt_avg", remainAmts[2]);
            resMap.put(cate + "_" + diffDays + "_remain_amt_std", remainAmts[3]);
        }

        Object[] wkedremainAmts = smsInfoTools.calcMinMaxAvgStd(weekendRemainAmtList);
        if (wkedremainAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekend_remain_amt_min", wkedremainAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekend_remain_amt_max", wkedremainAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekend_remain_amt_avg", wkedremainAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekend_remain_amt_std", wkedremainAmts[3]);
        }
        if (diffDays.equals("d30")) {
            Object[] wkedremainAmts2 = smsInfoTools.calcMinMaxAvgStd(weekendRemainAmtList2);
            if (wkedremainAmts2 != null) {
                resMap.put(cate + "_" + diffDays + "_weekend_remain_amt_min_2", wkedremainAmts2[0]);
            }
        }

        Object[] wkdyremainAmts = smsInfoTools.calcMinMaxAvgStd(weekDayRemainAmtList);
        if (wkdyremainAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekday_remain_amt_min", wkdyremainAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekday_remain_amt_max", wkdyremainAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekday_remain_amt_avg", wkdyremainAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekday_remain_amt_std", wkdyremainAmts[3]);
        }
        if (diffDays.equals("d30") || diffDays.equals("d90")) {
            Object[] wkdyremainAmts2 = smsInfoTools.calcMinMaxAvgStd(weekDayRemainAmtList2);
            if (wkdyremainAmts2 != null) {
                resMap.put(cate + "_" + diffDays + "_weekday_remain_amt_min_2", wkdyremainAmts2[0]);
                resMap.put(cate + "_" + diffDays + "_weekday_remain_amt_avg_2", wkdyremainAmts2[2]);
            }
        }

        Object[] outAmts = smsInfoTools.calcMinMaxAvgStd(outAmtList);
        if (outAmts != null) {
            resMap.put(cate + "_" + diffDays + "_out_amt_min", outAmts[0]);
            resMap.put(cate + "_" + diffDays + "_out_amt_max", outAmts[1]);
            resMap.put(cate + "_" + diffDays + "_out_amt_avg", outAmts[2]);
            resMap.put(cate + "_" + diffDays + "_out_amt_std", outAmts[3]);
        }
        Object[] wkedoutAmts = smsInfoTools.calcMinMaxAvgStd(weekendOutAmtList);
        if (wkedoutAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekend_out_amt_min", wkedoutAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekend_out_amt_max", wkedoutAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekend_out_amt_avg", wkedoutAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekend_out_amt_std", wkedoutAmts[3]);
        }

        Object[] wkdyoutAmts = smsInfoTools.calcMinMaxAvgStd(weekDayOutAmtList);
        if (wkdyoutAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekday_out_amt_min", wkdyoutAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekday_out_amt_max", wkdyoutAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekday_out_amt_avg", wkdyoutAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekday_out_amt_std", wkdyoutAmts[3]);
        }

        Object[] inAmts = smsInfoTools.calcMinMaxAvgStd(inAmtList);
        if (inAmts != null) {
            resMap.put(cate + "_" + diffDays + "_in_amt_min", inAmts[0]);
            resMap.put(cate + "_" + diffDays + "_in_amt_max", inAmts[1]);
            resMap.put(cate + "_" + diffDays + "_in_amt_avg", inAmts[2]);
            resMap.put(cate + "_" + diffDays + "_in_amt_std", inAmts[3]);
        }
        Object[] wkedinAmts = smsInfoTools.calcMinMaxAvgStd(weekendInAmtList);
        if (wkedinAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekend_in_amt_min", wkedinAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekend_in_amt_max", wkedinAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekend_in_amt_avg", wkedinAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekend_in_amt_std", wkedinAmts[3]);
        }

        Object[] wkdyinAmts = smsInfoTools.calcMinMaxAvgStd(weekDayInAmtList);
        if (wkdyinAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekday_in_amt_min", wkdyinAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekday_in_amt_max", wkdyinAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekday_in_amt_avg", wkdyinAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekday_in_amt_std", wkdyinAmts[3]);
        }

        if (diffDays.equals("d30")) {
            Object[] wkdyinAmts2 = smsInfoTools.calcMinMaxAvgStd(weekDayInAmtList2);
            if (wkdyinAmts2 != null) {
                resMap.put(cate + "_" + diffDays + "_weekday_in_amt_std_2", wkdyinAmts2[3]);
            }
        }
    }

    public void smsCrdtProcess(SmsInfoBasic basicInfo, SimpleDateFormat sdf) {
        cnt += 1; // 信用卡总条数
        String body_name = basicInfo.getBody_name();
        long recvTime = basicInfo.getRecvTime();
        String date = sdf.format(new Date(recvTime));

        daySet.add(date);
        if (body_name != null) {
            orgSet.add(body_name);
        }

        int isWeekend = basicInfo.getIsWeekend();
        int isWeekend2 = basicInfo.getIsWeekend2();
        if (isWeekend == 1) {
            wked_cnt += 1;
            wkedDaySet.add(date);
            if (body_name != null) {
                wkedOrgSet.add(body_name);
            }
        } else {
            wkdy_cnt += 1;
            wkdyDaySet.add(date);
            if (body_name != null) {
                wkdyOrgSet.add(body_name);
            }
        }

        BigDecimal crdtCosuAmt = basicInfo.getCrdtCosuAmt();
        BigDecimal crdtAmt = basicInfo.getCrdtAmt();

        if (crdtAmt != null) {
            crdtAmtList.add(crdtAmt);
            if (isWeekend == 1) {
                weekendcrdtAmtList.add(crdtAmt);
            } else {
                weekDaycrdtAmtList.add(crdtAmt);
            }

            if (isWeekend2 != 1) {
                weekDaycrdtAmtList2.add(crdtAmt);
            }
        }

        if (crdtCosuAmt != null) {
            crdtcosuAmtList.add(crdtCosuAmt);
            if (isWeekend == 1) {
                weekendcrdtcosuAmtList.add(crdtCosuAmt);
            } else {
                weekDaycrdtcosuAmtList.add(crdtCosuAmt);
            }
        }
    }

    private void smsCrdtCalcLabel(String diffDays) {
        resMap.put(cate + "_" + diffDays + "_cnt", cnt);
        resMap.put(cate + "_" + diffDays + "_days", daySet.size());
        resMap.put(cate + "_" + diffDays + "_org_cnt", orgSet.size());

        resMap.put(cate + "_" + diffDays + "_weekday_cnt", wkdy_cnt);
        resMap.put(cate + "_" + diffDays + "_weekday_days", wkdyDaySet.size());
        resMap.put(cate + "_" + diffDays + "_weekday_org_cnt", wkdyOrgSet.size());

        resMap.put(cate + "_" + diffDays + "_weekend_cnt", wked_cnt);
        resMap.put(cate + "_" + diffDays + "_weekend_days", wkedDaySet.size());
        resMap.put(cate + "_" + diffDays + "_weekend_org_cnt", wkedOrgSet.size());

        Object[] crdtAmts = smsInfoTools.calcMinMaxAvgStd(crdtAmtList);
        if (crdtAmts != null) {
            resMap.put(cate + "_" + diffDays + "_remamt_min", crdtAmts[0]);
            resMap.put(cate + "_" + diffDays + "_remamt_max", crdtAmts[1]);
            resMap.put(cate + "_" + diffDays + "_remamt_avg", crdtAmts[2]);
            resMap.put(cate + "_" + diffDays + "_remamt_std", crdtAmts[3]);
        }
        Object[] weekDayCrdtAmts = smsInfoTools.calcMinMaxAvgStd(weekDaycrdtAmtList);
        if (weekDayCrdtAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekday_remamt_min", weekDayCrdtAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekday_remamt_max", weekDayCrdtAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekday_remamt_avg", weekDayCrdtAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekday_remamt_std", weekDayCrdtAmts[3]);
        }
        if (diffDays.equals("d365")) {
            Object[] weekDayCrdtAmts2 = smsInfoTools.calcMinMaxAvgStd(weekDaycrdtAmtList2);
            if (weekDayCrdtAmts2 != null) {
                resMap.put(cate + "_" + diffDays + "_weekday_remamt_min_2", weekDayCrdtAmts2[0]);
            }
        }
        Object[] weekednCrdtAmts = smsInfoTools.calcMinMaxAvgStd(weekendcrdtAmtList);
        if (weekednCrdtAmts != null) {
            resMap.put(cate + "_" + diffDays + "_weekend_remamt_min", weekednCrdtAmts[0]);
            resMap.put(cate + "_" + diffDays + "_weekend_remamt_max", weekednCrdtAmts[1]);
            resMap.put(cate + "_" + diffDays + "_weekend_remamt_avg", weekednCrdtAmts[2]);
            resMap.put(cate + "_" + diffDays + "_weekend_remamt_std", weekednCrdtAmts[3]);
        }

        Object[] crdtCosuAmts = smsInfoTools.calcMinMaxAvgStd(crdtcosuAmtList);
        if (crdtCosuAmts != null) {
            resMap.put(cate + "_" + diffDays + "_cosmamt_min", crdtCosuAmts[0]);
            resMap.put(cate + "_" + diffDays + "_cosmamt_max", crdtCosuAmts[1]);
            resMap.put(cate + "_" + diffDays + "_cosmamt_avg", crdtCosuAmts[2]);
            resMap.put(cate + "_" + diffDays + "_cosmamt_std", crdtCosuAmts[3]);
        }
        /** 信用卡消费金额没有针对工作日和双休日维度的label */
    }

    public void smsItntProcess(SmsInfoBasic basicInfo, SimpleDateFormat sdf) {
        cnt += 1; // 互金总条数
        String body_name = basicInfo.getBody_name();
        long recvTime = basicInfo.getRecvTime();
        String date = sdf.format(new Date(recvTime));

        /** 互金可用额度 */
        BigDecimal loanLineAmt = basicInfo.getLoanLineAmt();
        /** 还款金额 */
        BigDecimal loanRepayAmt = basicInfo.getLoanRepayAmt();

        daySet.add(date);
        if (body_name != null) {
            orgSet.add(body_name);
        }

        int isWeekend = basicInfo.getIsWeekend();
        int isWeekend2 = basicInfo.getIsWeekend2();
        if (isWeekend == 1) {
            wked_cnt += 1;
            wkedDaySet.add(date);
            if (body_name != null) {
                wkedOrgSet.add(body_name);
            }
        } else {
            wkdy_cnt += 1;
            wkdyDaySet.add(date);
            if (body_name != null) {
                wkdyOrgSet.add(body_name);
            }
        }

        if (loanLineAmt != null) {
            loanLineAmtList.add(loanLineAmt);
            if (isWeekend == 1) {
                weekendLoanLineAmtList.add(loanLineAmt);
            } else {
                weekDayLoanLineAmtList.add(loanLineAmt);
            }
        }

        if (loanRepayAmt != null) {
            loanRepayAmtList.add(loanRepayAmt);
            if (isWeekend == 1) {
                weekendLoanRepayAmtList.add(loanRepayAmt);
            } else {
                weekDayLoanRepayAmtList.add(loanRepayAmt);
            }
            if (isWeekend2 != 1) {
                weekDayLoanRepayAmtList2.add(loanRepayAmt);
            }
        }

        int isLoanApplySucc = basicInfo.getIsLoanApplySucc();
        int isLoanRepayRemind = basicInfo.getIsLoanRepayRemind();
        int isLoanRepaySucc = basicInfo.getIsLoanRepaySucc();
        int isLoanRepayFail = basicInfo.getIsLoanRepayFail();

        if (isLoanApplySucc == 1) {
            apply_success_cnt += 1;
            applySuccDaySet.add(date);
            if (body_name != null) {
                applySuccOrgSet.add(body_name);
            }
            if (isWeekend == 1) {
                weekend_apply_success_cnt += 1;
                wkedApplySuccDaySet.add(date);
                if (body_name != null) {
                    wkedApplySuccOrgSet.add(body_name);
                }
            } else {
                weekday_apply_success_cnt += 1;
                wkdyApplySuccDaySet.add(date);
                if (body_name != null) {
                    wkdyApplySuccOrgSet.add(body_name);
                }
            }
        }

        if (isLoanRepayRemind == 1) {
            repay_remind_cnt += 1;
            repayRemindDaySet.add(date);
            if (body_name != null) {
                repayRemindOrgSet.add(body_name);
            }
            if (isWeekend == 1) {
                weekend_repay_remind_cnt += 1;
                wkedRepayRemindDaySet.add(date);
                if (body_name != null) {
                    wkedRepayRemindOrgSet.add(body_name);
                }
            } else {
                weekday_repay_remind_cnt += 1;
                wkdyRepayRemindDaySet.add(date);
                if (body_name != null) {
                    wkdyRepayRemindOrgSet.add(body_name);
                }
            }
        }

        if (isLoanRepaySucc == 1) {
            repay_succ_cnt += 1;
            repaySuccDaySet.add(date);
            if (body_name != null) {
                repaySuccOrgSet.add(body_name);
            }
            if (isWeekend == 1) {
                weekend_repay_succ_cnt += 1;
                wkedRepaySuccDaySet.add(date);
                if (body_name != null) {
                    wkedRepaySuccOrgSet.add(body_name);
                }
            } else {
                weekday_repay_succ_cnt += 1;
                wkdyRepaySuccDaySet.add(date);
                if (body_name != null) {
                    wkdyRepaySuccOrgSet.add(body_name);
                }
            }
        }

        if (isLoanRepayFail == 1) {
            repay_fail_cnt += 1;
            repayFailDaySet.add(date);
            if (body_name != null) {
                repayFailOrgSet.add(body_name);
            }
            if (isWeekend == 1) {
                weekend_repay_fail_cnt += 1;
                wkedRepayFailDaySet.add(date);
                if (body_name != null) {
                    wkedRepayFailOrgSet.add(body_name);
                }
            } else {
                weekday_repay_fail_cnt += 1;
                wkdyRepayFailDaySet.add(date);
                if (body_name != null) {
                    wkdyRepayFailOrgSet.add(body_name);
                }
            }

            if (isWeekend2 != 1) {
                weekday_repay_fail_cnt2 += 1;
            }
        }
    }

    private void smsItntCalcLabel(String diffDays) {
        resMap.put(cate + "_" + diffDays + "_cnt", cnt);
        resMap.put(cate + "_" + diffDays + "_days", daySet.size());
        resMap.put(cate + "_" + diffDays + "_org_orgs", orgSet.size());
        resMap.put(cate + "_weekday_" + diffDays + "_cnt", wkdy_cnt);
        resMap.put(cate + "_weekday_" + diffDays + "_days", wkdyDaySet.size());
        resMap.put(cate + "_weekday_" + diffDays + "_org_orgs", wkdyOrgSet.size());
        resMap.put(cate + "_weekend_" + diffDays + "_cnt", wked_cnt);
        resMap.put(cate + "_weekend_" + diffDays + "_days", wkedDaySet.size());
        resMap.put(cate + "_weekend_" + diffDays + "_org_orgs", wkedOrgSet.size());

        resMap.put(cate + "_applypass_" + diffDays + "_cnt", apply_success_cnt);
        resMap.put(cate + "_applypass_" + diffDays + "_days", applySuccDaySet.size());
        resMap.put(cate + "_applypass_" + diffDays + "_orgs", applySuccOrgSet.size());
        resMap.put(cate + "_weekday_applypass_" + diffDays + "_cnt", weekday_apply_success_cnt);
        resMap.put(cate + "_weekday_applypass_" + diffDays + "_days", wkdyApplySuccDaySet.size());
        resMap.put(cate + "_weekday_applypass_" + diffDays + "_orgs", wkdyApplySuccOrgSet.size());
        resMap.put(cate + "_weekend_applypass_" + diffDays + "_cnt", weekend_apply_success_cnt);
        resMap.put(cate + "_weekend_applypass_" + diffDays + "_days", wkedApplySuccDaySet.size());
        resMap.put(cate + "_weekend_applypass_" + diffDays + "_orgs", wkedApplySuccOrgSet.size());

        resMap.put(cate + "_repayremind_" + diffDays + "_cnt", repay_remind_cnt);
        resMap.put(cate + "_repayremind_" + diffDays + "_days", repayRemindDaySet.size());
        resMap.put(cate + "_repayremind_" + diffDays + "_orgs", repayRemindOrgSet.size());
        resMap.put(cate + "_weekday_repayremind_" + diffDays + "_cnt", weekday_repay_remind_cnt);
        resMap.put(
                cate + "_weekday_repayremind_" + diffDays + "_days", wkdyRepayRemindDaySet.size());
        resMap.put(
                cate + "_weekday_repayremind_" + diffDays + "_orgs", wkdyRepayRemindOrgSet.size());
        resMap.put(cate + "_weekend_repayremind_" + diffDays + "_cnt", weekend_repay_remind_cnt);
        resMap.put(
                cate + "_weekend_repayremind_" + diffDays + "_days", wkedRepayRemindDaySet.size());
        resMap.put(
                cate + "_weekend_repayremind_" + diffDays + "_orgs", wkedRepayRemindOrgSet.size());

        resMap.put(cate + "_repaysuc_" + diffDays + "_cnt", repay_succ_cnt);
        resMap.put(cate + "_repaysuc_" + diffDays + "_days", repaySuccDaySet.size());
        resMap.put(cate + "_repaysuc_" + diffDays + "_orgs", repaySuccOrgSet.size());
        resMap.put(cate + "_weekday_repaysuc_" + diffDays + "_cnt", weekday_repay_succ_cnt);
        resMap.put(cate + "_weekday_repaysuc_" + diffDays + "_days", wkdyRepaySuccDaySet.size());
        resMap.put(cate + "_weekday_repaysuc_" + diffDays + "_orgs", wkdyRepaySuccOrgSet.size());
        resMap.put(cate + "_weekend_repaysuc_" + diffDays + "_cnt", weekend_repay_succ_cnt);
        resMap.put(cate + "_weekend_repaysuc_" + diffDays + "_days", wkedRepaySuccDaySet.size());
        resMap.put(cate + "_weekend_repaysuc_" + diffDays + "_orgs", wkedRepaySuccOrgSet.size());

        resMap.put(cate + "_repayfail_" + diffDays + "_cnt", repay_fail_cnt);
        resMap.put(cate + "_repayfail_" + diffDays + "_days", repayFailDaySet.size());
        resMap.put(cate + "_repayfail_" + diffDays + "_orgs", repayFailOrgSet.size());
        resMap.put(cate + "_weekday_repayfail_" + diffDays + "_cnt", weekday_repay_fail_cnt);
        if (diffDays.equals("d30")) {
            resMap.put(cate + "_weekday_repayfail_" + diffDays + "_cnt_2", weekday_repay_fail_cnt2);
        }
        resMap.put(cate + "_weekday_repayfail_" + diffDays + "_days", wkdyRepayFailDaySet.size());
        resMap.put(cate + "_weekday_repayfail_" + diffDays + "_orgs", wkdyRepayFailOrgSet.size());
        resMap.put(cate + "_weekend_repayfail_" + diffDays + "_cnt", weekend_repay_fail_cnt);
        resMap.put(cate + "_weekend_repayfail_" + diffDays + "_days", wkedRepayFailDaySet.size());
        resMap.put(cate + "_weekend_repayfail_" + diffDays + "_orgs", wkedRepayFailOrgSet.size());

        Object[] loanLineAmts = smsInfoTools.calcMinMaxAvgStd(loanLineAmtList);
        if (loanLineAmts != null) {
            resMap.put(cate + "_line_" + diffDays + "_min", loanLineAmts[0]);
            resMap.put(cate + "_line_" + diffDays + "_max", loanLineAmts[1]);
            resMap.put(cate + "_line_" + diffDays + "_avg", loanLineAmts[2]);
            resMap.put(cate + "_line_" + diffDays + "_std", loanLineAmts[3]);
        }
        Object[] weekDayloanLineAmts = smsInfoTools.calcMinMaxAvgStd(weekDayLoanLineAmtList);
        if (weekDayloanLineAmts != null) {
            resMap.put(cate + "_weekday_line_" + diffDays + "_min", weekDayloanLineAmts[0]);
            resMap.put(cate + "_weekday_line_" + diffDays + "_max", weekDayloanLineAmts[1]);
            resMap.put(cate + "_weekday_line_" + diffDays + "_avg", weekDayloanLineAmts[2]);
            resMap.put(cate + "_weekday_line_" + diffDays + "_std", weekDayloanLineAmts[3]);
        }
        Object[] weekendLoanLineAmts = smsInfoTools.calcMinMaxAvgStd(weekendLoanLineAmtList);
        if (weekendLoanLineAmts != null) {
            resMap.put(cate + "_weekend_line_" + diffDays + "_min", weekendLoanLineAmts[0]);
            resMap.put(cate + "_weekend_line_" + diffDays + "_max", weekendLoanLineAmts[1]);
            resMap.put(cate + "_weekend_line_" + diffDays + "_avg", weekendLoanLineAmts[2]);
            resMap.put(cate + "_weekend_line_" + diffDays + "_std", weekendLoanLineAmts[3]);
        }

        Object[] loanRepayAmts = smsInfoTools.calcMinMaxAvgStd(loanRepayAmtList);
        if (loanRepayAmts != null) {
            resMap.put(cate + "_repayamt_" + diffDays + "_min", loanRepayAmts[0]);
            resMap.put(cate + "_repayamt_" + diffDays + "_max", loanRepayAmts[1]);
            resMap.put(cate + "_repayamt_" + diffDays + "_avg", loanRepayAmts[2]);
            resMap.put(cate + "_repayamt_" + diffDays + "_std", loanRepayAmts[3]);
        }
        Object[] weekDayLoanRepayAmts = smsInfoTools.calcMinMaxAvgStd(weekDayLoanRepayAmtList);
        if (weekDayLoanRepayAmts != null) {
            resMap.put(cate + "_weekday_repayamt_" + diffDays + "_min", weekDayLoanRepayAmts[0]);
            resMap.put(cate + "_weekday_repayamt_" + diffDays + "_max", weekDayLoanRepayAmts[1]);
            resMap.put(cate + "_weekday_repayamt_" + diffDays + "_avg", weekDayLoanRepayAmts[2]);
            resMap.put(cate + "_weekday_repayamt_" + diffDays + "_std", weekDayLoanRepayAmts[3]);
        }
        if (diffDays.equals("d30") || diffDays.equals("d90")) {
            Object[] weekDayLoanRepayAmts2 =
                    smsInfoTools.calcMinMaxAvgStd(weekDayLoanRepayAmtList2);
            if (weekDayLoanRepayAmts2 != null) {
                resMap.put(
                        cate + "_weekday_repayamt_" + diffDays + "_max_2",
                        weekDayLoanRepayAmts2[1]);
                resMap.put(
                        cate + "_weekday_repayamt_" + diffDays + "_std_2",
                        weekDayLoanRepayAmts2[3]);
            }
        }
        Object[] weekendLoanRepayAmts = smsInfoTools.calcMinMaxAvgStd(weekendLoanRepayAmtList);
        if (weekendLoanRepayAmts != null) {
            resMap.put(cate + "_weekend_repayamt_" + diffDays + "_min", weekendLoanRepayAmts[0]);
            resMap.put(cate + "_weekend_repayamt_" + diffDays + "_max", weekendLoanRepayAmts[1]);
            resMap.put(cate + "_weekend_repayamt_" + diffDays + "_avg", weekendLoanRepayAmts[2]);
            resMap.put(cate + "_weekend_repayamt_" + diffDays + "_std", weekendLoanRepayAmts[3]);
        }
    }

    public void smsOdProcess(SmsInfoBasic basicInfo, SimpleDateFormat sdf) {
        cnt += 1;
        long recvTime = basicInfo.getRecvTime();
        String date = sdf.format(new Date(recvTime));
        daySet.add(date);

        String body_name = basicInfo.getBody_name();
        if (body_name != null) {
            orgSet.add(body_name);
        }

        int isItntLend = basicInfo.getIsItntLend();
        if (isItntLend == 1) {
            loan_od_cnt += 1;
            loanOdDaySet.add(date);
            if (body_name != null) {
                loanOdOrgSet.add(body_name);
            }
        }
    }

    private void smsOdCalcLabel(String diffDays) {
        resMap.put(cate + "_" + diffDays + "_cnt", cnt);
        resMap.put(cate + "_" + diffDays + "_days", daySet.size());
        resMap.put(cate + "_" + diffDays + "_orgcnt", orgSet.size());

        resMap.put("sms_loan_od_" + diffDays + "_cnt", loan_od_cnt);
        resMap.put("sms_loan_od_" + diffDays + "_days", loanOdDaySet.size());
        resMap.put("sms_loan_od_" + diffDays + "_orgcnt", loanOdOrgSet.size());
    }

    public void smsCalcLable(String diffDays) {
        if (cate.equals(BASE)) {
            smsBaseCalcLabel(diffDays);
        }

        if (cate.equals(TELE) || cate.equals(EXPS) || cate.equals(SERV) || cate.equals(PAYT)) {
            smsCateCalcLabel(diffDays);
        }
        if (cate.equals(BANK)) {
            smsBankCalcLabel(diffDays);
        }
        if (cate.equals(CRDT)) {
            smsCrdtCalcLabel(diffDays);
        }
        if (cate.equals(LOAN)) {
            smsItntCalcLabel(diffDays);
        }
        if (cate.equals(OD)) {
            smsOdCalcLabel(diffDays);
        }
    }

    public HashMap<String, Object> getResMap() {
        return resMap;
    }
}
